<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../header.jsp">
	<jsp:param value="我的用户查看" name="title" />
</jsp:include>
<script type="text/javascript" src="static/js/counselor.js"></script>
<script type="text/javascript"
	src="${basePath }My97DatePicker/WdatePicker.js"></script>
<link href="static/css/couselor.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
	//刷新
	$(function() {
		$('#refresh').on('click', function() {
			location.replace("${basePath}${url}?id=${stuDetail.id}");
		});
		$('#dele').on('click', function() {
			if (confirm('确认删除？')) {
				location.replace("counselor/delete?id=${stuDetail.id}");
			}
		});
	});
	//修改跟进记录
	function change(stuId, recordId) {
		$('.modal.record').modal('show');
		var $stuId = $('#stuId');
		var $recordId = $('#recordId');
		$recordId.attr('value', recordId);
		$stuId.attr('value', stuId);
	}
	//判断跟进时间是否大于下一次跟进时间
	function recordTime() {
		$('#btn_save').attr("disabled", "disabled");
		$('#fileupload').attr("disabled", "disabled");
		var $start = $('#start');
		var $end = $('#end');
			if ($start.val() > $end.val()) {
				alert("起止时间大于结束时间！");
			} else {
				if ($('#text').val().length > 0) {
					$('#btn_save').removeAttr("disabled");
					$('#fileupload').removeAttr("disabled");
				}
			}
	}
	function inputContent() {
		$('#btn_save').attr("disabled", "disabled");
		$('#fileupload').attr("disabled", "disabled");
		var $start = $('#start');
		var $end = $('#end');
		if($start.val() < $end.val()){
			if ($('#text').val().length > 0) {
				$('#btn_save').removeAttr("disabled");
				$('#fileupload').removeAttr("disabled");
			}
		}
	}
</script>
</head>
<body>
	<jsp:include page="../menu/menue.jsp"></jsp:include>
	<jsp:include page="change_record.jsp"></jsp:include>
	<jsp:include page="change_grade.jsp"></jsp:include>

	<div class="detailForm">
		<div class="ui segment">
			<h4 class="ui left floated detail ">
				<c:if test="${stuDetail.counselorId eq emplo.id}">
					<c:if test="${stuDetail.gradeId<5}">
						<a href="counselor/mycustomer" name="customerDetail"> 潜在学员 </a>
					</c:if>
				</c:if>
				<c:if test="${stuDetail.counselorId != emplo.id}">
					<a href="counselor/myfavor" name="customerDetail"> 协助学员 </a>
				</c:if>
				<c:if test="${stuDetail.gradeId>=5}">
					<a href="counselor/allocated" name="customerDetail"> 已分配部门学员 </a>
				</c:if>
				>查看
			</h4>
			<div class="ui clearing divider"></div>
			<div class="ui teal basic button" tabindex="0" id="refresh">刷新</div>
			<c:if test="${stuDetail.gradeId<5}">
				<div class="ui teal basic button" tabindex="0" id="dele">删除</div>
			</c:if>
			<span style="color: red; margin-left: 20px;">${erro}</span>
			<c:if test="${stuRecordList[0].nextTime!=null}">
				<c:if test="${stuDetail.gradeId<5}">
					<span class="nextFollowTime">下一次跟进:<fmt:formatDate
							value="${stuRecordList[0].nextTime }" type="date" />
					</span>
				</c:if>
			</c:if>
			<div class="ui clearing divider"></div>
			<p></p>
			<div class="ui grid">
				<div class="frist wide column">
					<div class="ui special cards ">
						<div class="card">
							<div class="blurring dimmable image">
								<div class="ui dimmer">
									<div class="content">
										<div class="center">
											<div class="ui inverted button">
												<a href="${basePath}${url}?id=${stuDetail.id}#record"
													class="a_record">跟进记录</a>
											</div>
										</div>
									</div>
								</div>
								<img src="static/images/gongzi.png">
							</div>
							<div class="name content">
								<a class="header">${stuDetail.name}</a>
								<div class="meta">
									<span class="date">Create in <fmt:formatDate
											value="${stuDetail.createTime }" type="date"></fmt:formatDate></span>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="nine wide column">
					<p></p>
					<div class="ui computer reversed equal width grid">
						<div class="row">
							<div class="column">性别：${stuDetail.gender }</div>
							<div class="column">学历：${stuDetail.education }</div>
						</div>
						<div class="row">
							<div class="column">来源：${stuDetail.source }</div>
							<div class="column">电话：${stuDetail.phone }</div>
						</div>
					</div>
					<div class="ui tablet reversed equal width grid">
						<div class="column">QQ:${stuDetail.qq }</div>
						<div class="column">家庭住址：${stuDetail.address }</div>
					</div>
					<div class="ui mobile reversed equal width grid">
						<div class="column">父亲姓名：${stuDetail.fatherName}</div>
						<div class="column">父亲电话：${stuDetail.fatherTel}</div>
					</div>
					<div class="ui mobile reversed equal width grid">
						<div class="column">母亲姓名：${stuDetail.motherName}</div>
						<div class="column">母亲电话：${stuDetail.motherTel}</div>
					</div>
				</div>
				<div class="three wide column">
					<p></p>
					<div class="class">
						<c:if test="${stuDetail.gradeId<5}">
							<div class="ui massive star rating grade"
								id="${stuDetail.counselorId == emp.id? 'changeGrade01':''}"
								data-rating="${stuDetail.gradeId }" data-max-rating="4"></div>
						</c:if>
						<c:if test="${stuDetail.gradeId>5}">
							<div class="ui heart rating" data-rating="3" data-max-rating="3"></div>
						</c:if>
						<div class="className">
							<div
								id="${stuDetail.gradeId<5 && stuDetail.counselorId == emp.id ?'changeGrade02':''}">
								${stuDetail.stuGradeText }</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div>
			<div class="ui secondary pointing menu">
				<a class=" ${url eq 'customer/detail' ?'item active':'item' }"
					href="customer/detail?id=${stuDetail.id}" name="record"
					class="myRecord"> <c:if
						test="${stuDetail.counselorId eq emplo.id}">
					跟进记录
					</c:if> <c:if test="${stuDetail.counselorId != emplo.id}">我的协助</c:if>
				</a> <a class="${url eq 'counselor/dofavor'?'item active': 'item'}"
					href="counselor/dofavor?id=${stuDetail.id}"> <c:if
						test="${stuDetail.counselorId eq emplo.id}">
					协助记录
					</c:if> <c:if test="${stuDetail.counselorId != emplo.id}">跟进记录</c:if>
				</a>
				<c:if test="${stuDetail.gradeId<5}">
					<div class="right menu">
						<a class="ui item"
							href="${basePath}customer/detail?id=${stuDetail.id}#editor">
							<span> <img src="static/images/pen.png">
						</span> 写记录
						</a>
					</div>
				</c:if>
			</div>
			<c:if test="${empty stuRecordList }">
				<div class="ui segment">
					<div class="ui items">
						<div class="item">
							<div class="content">
								<div class="description">暂无跟进记录</div>
							</div>
						</div>
					</div>
				</div>
			</c:if>
			<c:if test="${url eq 'customer/detail'}">
				<c:forEach items="${stuRecordList }" var="stu">
					<div class="ui segment">
						<div class="ui items">
							<div class="item">
								<div class="content">
									<div class="header">
										跟进时间：
										<fmt:formatDate value="${stu.followTime}" type="date"></fmt:formatDate>
									</div>
									<div class="description">
										<div style="margin-bottom: 30px;">${stu.content}</div>
										<c:if test="${stu.attach > 0 }">
											<a target="_blank"
												href="view-attach?record=${stu.recordId }&model=follow_up">
												查看附件 </a>
										</c:if>
										<c:if test="${stu.attach eq 0 }">

										</c:if>
										<c:if test="${stuDetail.gradeId<5}">
											<div class="ui right floated button"
												onclick="change('${stuDetail.id}' , '${stu.recordId }')">修改</div>
										</c:if>
										<div class="metadata recordTime">
											<div class="date">
												<div class="metadata">
													<div class="date">
														<fmt:formatDate value="${stu.recordTime }" type="both" />
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</c:forEach>
				<c:if test="${totalPage > 1 }">
					<div class="page">
						<a
							<c:if test="${page!=1}">href="${url}?id=${stuDetail.id}&page=1${queryString}"</c:if>
							class="${page==1?'disable':'' }">首页</a> <a
							<c:if test="${page!=1}">href="${url}?id=${stuDetail.id}&page=${page-1}${queryString}"</c:if>
							class="${page==1?'disable':''}">上一页</a> <a
							<c:if test="${page!=totalPage}">href="${url}?id=${stuDetail.id}&page=${page+1 }${queryString}"</c:if>
							class="${page==totalPage?'disable':''}">下一页</a> <a
							<c:if test="${page!=totalPage}">href="${url}?id=${stuDetail.id}&page=${totalPage }${queryString}"</c:if>
							class="${page==totalPage?'disable':''}">最后一页</a> <span
							class="tag">${page}/${ totalPage} </span>
					</div>
				</c:if>
			</c:if>
			<c:if test="${url eq 'counselor/dofavor'}">
				<c:forEach items="${stuRecordList }" var="stu">
					<div class="ui comments">
						<div class="comment">
							<a class="avatar"> <img src="static/images/round.jpg">
							</a>
							<div class="content">
								<a class="author">${stu.assitstEmpName}</a>
								<div class="metadata">
									<div class="date">
										开始协助：
										<fmt:formatDate value="${stu.asCreateTime }" type="both" />
									</div>
								</div>
								<div class="ui piled segment">
									${stu.content}
									<p>
									<div class="metadata">
										<div class="date">
											<fmt:formatDate value="${stu.recordTime }" type="both" />
										</div>
									</div>
									<p>
								</div>
							</div>
						</div>
					</div>
				</c:forEach>
				<c:if test="${totalPage > 1 }">
					<div class="page">
						<a
							<c:if test="${page!=1}">href="${url}?id=${stuDetail.id}&page=1${queryString}"</c:if>
							class="${page==1?'disable':'' }">首页</a> <a
							<c:if test="${page!=1}">href="${url}?id=${stuDetail.id}&page=${page-1}${queryString}"</c:if>
							class="${page==1?'disable':''}">上一页</a> <a
							<c:if test="${page!=totalPage}">href="${url}?id=${stuDetail.id}&page=${page+1 }${queryString}"</c:if>
							class="${page==totalPage?'disable':''}">下一页</a> <a
							<c:if test="${page!=totalPage}">href="${url}?id=${stuDetail.id}&page=${totalPage }${queryString}"</c:if>
							class="${page==totalPage?'disable':''}">最后一页</a> <span
							class="tag">${page}/${ totalPage} </span>
					</div>
				</c:if>
			</c:if>
			<c:if test="${stuDetail.gradeId<5}">
				<c:if test="${url eq 'customer/detail'}">
					<div class="ui segment record">
						<h4 class="ui left floated detail ">
							<a href="customer/detail?id=${stuDetail.id}#customerDetail">${stuDetail.name}</a>>跟进记录
						</h4>
						<div class="ui clearing divider"></div>
						<div class="ui comments">
							<a name="editor"></a>
							<div class="comment">
								<div class="content">
									<form class="ui reply form" method="post">
										<input type="hidden" value="${stuDetail.id}" name="stuId">
										<div class="field">
											<div style="font-size: 16px;" class="editor record">
												<span>跟进时间：</span> <img src="static/images/calendar.png"></img>
												<input type="text" onfocus="WdatePicker()" class="Wdate"
													style="width: 150px; height: 26px; margin-right: 10px;"
													id="start" onchange="recordTime()" placeholder="跟进时间" value="${now }"
													name="followTime" /> <span>下次跟进：</span> <img
													src="static/images/calendar.png"></img> <input type="text" 
													onfocus="WdatePicker()" class="Wdate"
													style="width: 150px; height: 26px;" placeholder="下一次跟进"
													id="end" onchange="recordTime()" name="nextTime" />
											</div>
											<textarea name="recordContent" id="text"
												onkeyup="inputContent()" onchange="inputContent()"></textarea>
										</div>
										<div class="files"></div>

										<span class="btn btn-success fileinput-button"> <span
											class="fileinput-text">选择文件</span> <input id="fileupload" disabled="disabled"
											type="file" name="files[]">
										</span>
										<button class="ui primary button" id="btn_save"
											disabled="disabled">保存</button>
									</form>
								</div>
							</div>
						</div>
					</div>
				</c:if>
			</c:if>
		</div>
	</div>
</body>
</html>